#!/bin/sh

# stop blowing compiled stuff
rm -rf builds/out-self-parity
mkdir -p builds/out-self-parity

# extract needed files from clojure.jar
if [ ! -f lib/clojure.jar ]; then
  echo "Run script/bootstrap first"
  exit 1
fi
jar xvf lib/clojure.jar clojure/template.clj > /dev/null
unzip lib/test.check.jar 'clojure/*' > /dev/null
mkdir -p builds/out-self-parity/clojure/test
mv clojure/template.clj builds/out-self-parity/clojure
mv clojure/test builds/out-self-parity/clojure

if ! bin/cljsc src/test/self/self_parity "{:optimizations :simple :language-in :es6 :language-out :es5 :output-to \"builds/out-self-parity/main.js\" :output-dir \"builds/out-self-parity\" :main self-parity.test :target :nodejs}"; then
  >&2 echo ClojureScript compilation failed
  exit 1
fi;

echo "Testing with Node"
node builds/out-self-parity/main.js
